home *** CD-ROM | disk | FTP | other *** search
Wrap
/* ** $VER: BatchConvert.ieb 1.31, IE Arexx script ** Image Engineer Batch Processing script ** Copyright © by Patrik M Nydensten ** 25/1 1997 Stockholm/Sweden ** ** Convert all selected images to a user selected file format. */ options results signal on error parse arg input command input = upper(strip(input)) address 'IMAGEENGINEER' select /* Required batch script commands */ when input = 'INFO' then return get_info() when input = 'CONFIG' then return get_config(command) when input = 'PROCESS' then return process_image(command) otherwise do 'REQUEST' '"Failure in call to batch script!"' '" Quit "' return '<ERROR>' end end exit 0 /* Required "Get_info" procedure ------------------------------------ */ /* S = SECONDARY, A = ALPHA, 1 = Single file, 2 = Multiple files */ get_info: back = 'OK' return back /* Required "Get_config" procedure ---------------------------------- */ get_config: parse arg '"'command'"' 'IE_TO_FRONT' /* Unchanged config, only picked for first image */ form = 'FORM "BatchConvert" " OK | Cancel "' if command = '' then do 'GET_FILE_TYPE "Select destination file format."' if (RC ~= 0) then return '<ERROR>' FileType = result 'REQUEST' '"Would you like to save as rendered or 24bit images?"' '" Render | 24bit "' qrender = result if qrender = 1 then do 'RENDER_GET' '"Set render options."' '0 135168 8 256 1 0' if (RC ~= 0) then return '<ERROR>' RenderOptions = result if word(RenderOptions,5) = 0 then form = form||' FILE,"Lock-Palette","IE:Palettes/"' form = form||' CHECKBOX,"Show rendering in foreground?",1' end form = form||' CHECKBOX,"Strip last non-number suffix?",0', ' STRING,"New file suffix","'word(FileType,1)'",10' form parse var result ok rest if ok = 0 then return '<ERROR>' if word(RenderOptions,5) = 0 then parse var rest '"'qpalette'"' rest else qpalette = 'none' if qrender = 1 then parse var rest Show_render rest else Show_render = 'none' parse var rest Strip_name '"'ext'"' end /* command */ else do 'REQUEST' '"The BatchConvert.ieb script does only'd2c(10)||, 'have settings for the first image."' '" OK "' FileType = 'none' qrender = 'none' RenderOptions = 'none' qpalette = 'none' Show_render = 'none' Strip_name = 'none' ext = 'none' end RenderOptions = translate(RenderOptions,'-',' ') FileType = translate(FileType,'ª',' ') qpalette = translate(qpalette,'ª',' ') back = '#'FileType '#'qrender '#'RenderOptions '#'qpalette '#'strip(Show_render) '#'strip(Strip_name) '#'strip(ext) return back /* Required "Process_image" procedure ------------------------------- */ process_image: parse arg '"'src_image'"' '"'dst_image'"' '"'options'"' parse var options '#'FileType '#'qrender '#'RenderOptions '#'qpalette '#'Show_render '#'Strip_name '#'ext . 'OPEN' '"'src_image'"' '24' if (RC ~= 0) then do 'IE_TO_FRONT' 'REQUEST' '"Failed to load image:' d2c(10)||src_image'"' '" OK "' return '<ERROR>' end else LoadImage = result RenderOptions = strip(translate(RenderOptions,' ','-')) FileType = strip(translate(FileType,' ','ª')) qpalette = strip(translate(qpalette,' ','ª')) ext = '.'||strip(ext) if strip(ext) = '.' then ext = '' /* Remove last non-number suffix */ if Strip_name = 1 then do if datatype( get_ext(src_image) ,'N') then src_image = get_base(get_base(src_image)) || '.'get_ext(src_image) else src_image = get_base(src_image) end /* Set new name */ if datatype( get_ext(src_image) ,'N') then dst_image = get_path(dst_image) || get_base(get_file(src_image)) || ext || '.'get_ext(src_image) else dst_image = get_path(dst_image) || get_file(src_image) || ext if (strip(qrender) = 1) then do if word(RenderOptions,5) = 0 then 'PALETTE_LOAD' LoadImage '"'qpalette'"' 'RENDER_SET' LoadImage RenderOptions If Show_render = 1 then 'RENDER' LoadImage else 'RENDER' LoadImage 'QUIET' 'SAVE' LoadImage '"'dst_image'"' '"'||filetype||'"' if (RC ~= 0) then do 'REQUEST' '"Error when saving' LoadImage '!'LF, 'You have probably selected settings that are'LF, 'not possible to use with this file format."' '"Continue"' return '<ERROR>' end end /* render image */ else do 'SAVE_DATA' LoadImage '"'dst_image'"' '"'||filetype||'"' if (RC ~= 0) then do 'REQUEST' '"Error when saving' LoadImage '!'LF, 'You have probably selected settings that are'LF, 'not possible to use with this file format."' '"Continue"' return '<ERROR>' end end 'CLOSE' LoadImage back = 'OK' return back /* Internal procedures ---------------------------------------------- */ get_path: parse arg get_path_in if lastpos('/',get_path_in) ~= 0 then get_path_back = substr(get_path_in,1,lastpos('/',get_path_in)) else if lastpos(':',get_path_in) ~= 0 then get_path_back = substr(get_path_in,1,lastpos(':',get_path_in)) else get_path_back = '' return get_path_back get_file: parse arg get_file_in if lastpos('/',get_file_in) ~= 0 then get_file_back = substr(get_file_in,1+lastpos('/',get_file_in)) else if lastpos(':',get_file_in) ~= 0 then get_file_back = substr(get_file_in,1+lastpos(':',get_file_in)) else get_file_back = get_file_in return get_file_back get_ext: parse arg get_ext_in if lastpos('.',get_ext_in) ~= 0 then get_ext_back = substr(get_ext_in,1+lastpos('.',get_ext_in)) else get_ext_back = '' return get_ext_back get_base: parse arg get_base_in if lastpos('.',get_base_in) ~= 0 then get_base_back = substr(get_base_in,1,lastpos('.',get_base_in)-1) else get_base_back = get_base_in return get_base_back /*******************************************************************/ /* This is where control goes when an error code is returned by IE */ /* It puts up a message saying what happened and on which line */ /*******************************************************************/ error: if RC=5 then do IE_TO_FRONT LAST_ERROR 'REQUEST "'||RESULT||'"' end else do IE_TO_FRONT LAST_ERROR 'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!' end return '<ERROR>'